package code.c08;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/10/20 11:07
 * @package code.c08
 * @description 文件说明
 */

public class MapTest {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();

        map.put("1001", "张三普法");
        map.put("1002", "大罗翔");
        map.put("1003", "张国伟");

//        System.out.println(map);
//
//        if (map.containsKey("1001")) {
//            System.out.println(map.get("1001"));
//        }

        //  获取key的集合
        Set<String> strings = map.keySet();
//        System.out.println(strings);

        // map 迭代遍历
        Iterator<String> iterator = strings.iterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            System.out.println(key + ":" + map.get(key));
        }
    }
}
